﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ClassLibrary.Entity;
using ClassLibrary.DAO;
using ClassLibrary.Data;

public partial class UserControl_AddL2Phone : System.Web.UI.UserControl
{
    TblLoan2PhoneDAO Loan2PhoneDAO = new TblLoan2PhoneDAO(Global.CONNECTION_STRING);
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string id = Request.QueryString["id"];
        bool flag = false;
        try
        {
            TblLoan2Phone L2Phone = new TblLoan2Phone();
            L2Phone.LPhoneBrand = drBrand.SelectedValue;
            L2Phone.LPhoneModel = txtModel.Text;
            L2Phone.LPIMENo = txtIME.Text;
            L2Phone.AccessoriresIncluded = txt_access.Text;
            L2Phone.Deposit = Convert.ToDecimal(txt_amount.Text);
            L2Phone.LoanFee = Convert.ToDecimal(txt_loanfee.Text);
            L2Phone.LoanStatus = 0;
            L2Phone.Notes = txt_notes.Text;

            //insert Loan2Phone
            L2Phone.LPhoneID = "";
            Loan2PhoneDAO.InsUpd_L2Phone(L2Phone, 1);
            flag = true;
        }
        catch (Exception ex)
        {
            Session[Global.SESSION_ERROR] = ex;
            Response.Redirect(Global.ERROR_PAGE);
        }
        if (flag)
        {
            ScriptManager.RegisterStartupScript(btnSave, btnSave.GetType(), "ScriptLoginSuccess", "UpdateParentsLogin();", true);
        }
        
    }
}
